﻿using Scm.Jwt.Dto;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Scm.Service.Dto
{
    /// <summary>
    /// 基础返回对象
    /// </summary>
    /// <typeparam name="T"></typeparam>
    public class BaseDto<T>
    {
        public int? Code { get; set; }
        public string? Msg { get; set; }
        public T? Data { get; set; }
        public PageDto? Paged { get; set; }


        /// <summary>
        /// 错误返回
        /// </summary>
        /// <param name="Msg"></param>
        /// <param name="Code"></param>
        /// <returns></returns>
        public static BaseDto<T> ErrorMsg(string Msg, int? Code = 500)
        {
            return new BaseDto<T>
            {
                Msg = Msg,
                Code = Code
            };
        }


        /// <summary>
        /// 正常返回
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        public static BaseDto<T> Success(T Data,PageDto? Paged = null)
        {
            return new BaseDto<T>
            {
                Data = Data,
                Paged = Paged
            };
        }
    }

    
    /// <summary>
    /// 分页实体
    /// </summary>
    public class PageDto
    {
        public int Page { get; set; }
        public int Size { get; set; }
        public bool HasNext { get; set; }
    }

}
